﻿#ifndef COMBINESPLITWIDGET_H
#define COMBINESPLITWIDGET_H

#include <QDialog>
#include "formula.h"
#include "newformulastandarditemmodel.h"
#include "productservice.h"
#include "userservice.h"

namespace Ui {
class CombineSplitWidget;
}

class CombineSplitWidget : public QDialog
{
    Q_OBJECT

public:
    enum WidgetType{
        CombineWidget=1,
        SplitWidgetType=2,
    };

    Q_ENUM(WidgetType)

    explicit CombineSplitWidget(QWidget *parent = nullptr);
    ~CombineSplitWidget();

    void setWidgetTpe(WidgetType type);

    void initWithCombineId(QString combineId);

    void refreshBalance();

private slots:
    void on_pushButtonExit_clicked();

    void on_pushButtonSubmit_clicked();

    void on_lineEditCombineSplitCount_textChanged(const QString &arg1);

private:
    void initWithFormula(Formula *formula);

    Ui::CombineSplitWidget *ui;

    WidgetType widgetType;
    NewFormulaStandardItemModel *model;
    ProductService productService;
    UserService userService;

    Formula *formula;

    double currentTotal;
};

#endif // COMBINESPLITWIDGET_H
